# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.Compute.V1.Model.AutoscalingPolicy do
  @moduledoc """
  Cloud Autoscaler policy.

  ## Attributes

  *   `coolDownPeriodSec` (*type:* `integer()`, *default:* `nil`) - The number of seconds that your application takes to initialize on a VM instance. This is referred to as the [initialization period](/compute/docs/autoscaler#cool_down_period). Specifying an accurate initialization period improves autoscaler decisions. For example, when scaling out, the autoscaler ignores data from VMs that are still initializing because those VMs might not yet represent normal usage of your application. The default initialization period is 60 seconds. Initialization periods might vary because of numerous factors. We recommend that you test how long your application takes to initialize. To do this, create a VM and time your application's startup process.
  *   `cpuUtilization` (*type:* `GoogleApi.Compute.V1.Model.AutoscalingPolicyCpuUtilization.t`, *default:* `nil`) - Defines the CPU utilization policy that allows the autoscaler to scale based on the average CPU utilization of a managed instance group.
  *   `customMetricUtilizations` (*type:* `list(GoogleApi.Compute.V1.Model.AutoscalingPolicyCustomMetricUtilization.t)`, *default:* `nil`) - Configuration parameters of autoscaling based on a custom metric.
  *   `loadBalancingUtilization` (*type:* `GoogleApi.Compute.V1.Model.AutoscalingPolicyLoadBalancingUtilization.t`, *default:* `nil`) - Configuration parameters of autoscaling based on load balancer.
  *   `maxNumReplicas` (*type:* `integer()`, *default:* `nil`) - The maximum number of instances that the autoscaler can scale out to. This is required when creating or updating an autoscaler. The maximum number of replicas must not be lower than minimal number of replicas.
  *   `minNumReplicas` (*type:* `integer()`, *default:* `nil`) - The minimum number of replicas that the autoscaler can scale in to. This cannot be less than 0. If not provided, autoscaler chooses a default value depending on maximum number of instances allowed.
  *   `mode` (*type:* `String.t`, *default:* `nil`) - Defines the operating mode for this policy. The following modes are available: - OFF: Disables the autoscaler but maintains its configuration. - ONLY_SCALE_OUT: Restricts the autoscaler to add VM instances only. - ON: Enables all autoscaler activities according to its policy. For more information, see "Turning off or restricting an autoscaler"
  *   `scaleInControl` (*type:* `GoogleApi.Compute.V1.Model.AutoscalingPolicyScaleInControl.t`, *default:* `nil`) - 
  *   `scalingSchedules` (*type:* `%{optional(String.t) => GoogleApi.Compute.V1.Model.AutoscalingPolicyScalingSchedule.t}`, *default:* `nil`) - Scaling schedules defined for an autoscaler. Multiple schedules can be set on an autoscaler, and they can overlap. During overlapping periods the greatest min_required_replicas of all scaling schedules is applied. Up to 128 scaling schedules are allowed.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :coolDownPeriodSec => integer() | nil,
          :cpuUtilization => GoogleApi.Compute.V1.Model.AutoscalingPolicyCpuUtilization.t() | nil,
          :customMetricUtilizations =>
            list(GoogleApi.Compute.V1.Model.AutoscalingPolicyCustomMetricUtilization.t()) | nil,
          :loadBalancingUtilization =>
            GoogleApi.Compute.V1.Model.AutoscalingPolicyLoadBalancingUtilization.t() | nil,
          :maxNumReplicas => integer() | nil,
          :minNumReplicas => integer() | nil,
          :mode => String.t() | nil,
          :scaleInControl => GoogleApi.Compute.V1.Model.AutoscalingPolicyScaleInControl.t() | nil,
          :scalingSchedules =>
            %{
              optional(String.t()) =>
                GoogleApi.Compute.V1.Model.AutoscalingPolicyScalingSchedule.t()
            }
            | nil
        }

  field(:coolDownPeriodSec)
  field(:cpuUtilization, as: GoogleApi.Compute.V1.Model.AutoscalingPolicyCpuUtilization)

  field(:customMetricUtilizations,
    as: GoogleApi.Compute.V1.Model.AutoscalingPolicyCustomMetricUtilization,
    type: :list
  )

  field(:loadBalancingUtilization,
    as: GoogleApi.Compute.V1.Model.AutoscalingPolicyLoadBalancingUtilization
  )

  field(:maxNumReplicas)
  field(:minNumReplicas)
  field(:mode)
  field(:scaleInControl, as: GoogleApi.Compute.V1.Model.AutoscalingPolicyScaleInControl)

  field(:scalingSchedules,
    as: GoogleApi.Compute.V1.Model.AutoscalingPolicyScalingSchedule,
    type: :map
  )
end

defimpl Poison.Decoder, for: GoogleApi.Compute.V1.Model.AutoscalingPolicy do
  def decode(value, options) do
    GoogleApi.Compute.V1.Model.AutoscalingPolicy.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.Compute.V1.Model.AutoscalingPolicy do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
